

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="__STATIC__/layuiadmin/layui/css/layui.css" media="all">
</head>
<body>

<div class="layui-form" lay-filter="layuiadmin-form-role" id="layuiadmin-form-role" style="padding: 20px 30px 0 0;">

    <div class="layui-form-item">
        <label class="layui-form-label">菜单</label>
        <div class="layui-input-block">
            <select name="pid">
                <option value="0">顶级菜单</option>
                {notempty name="$menu"}
                    {volist name="menu" id="vo_menu"}
                        <option value="{$vo_menu.id}" {eq name="$vo_menu.id" value="$pid"}selected{/eq} >|{:str_repeat('--',$vo_menu.level)}&nbsp;{$vo_menu.title}</option>
                    {/volist}
                {/notempty}
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">名称</label>
        <div class="layui-input-inline">
            <input type="text" name="title" lay-verify="required" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">排序</label>
        <div class="layui-input-inline">
            <input type="number" name="sort" autocomplete="off" class="layui-input" value="0">
        </div>
        <div class="layui-form-mid layui-word-aux">大的在后面</div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">URL</label>
        <div class="layui-input-block">
            <input type="text" name="url" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="*">提交</button>
        </div>

    </div>
</div>

<script src="__STATIC__/layuiadmin/layui/layui.js"></script>
<script>
    layui.use(['form'], function () {
        var form = layui.form
            ,$ = layui.jquery
            ,layer = layui.layer;

        form.on('submit(*)', function(data){
            $.post("{:url('menu/save')}",data.field,function (ret) {
                if (ret.code == 0){
                    layer.msg(ret.msg,{icon:6,time:1500},function () {
                        parent.layer.closeAll();
                    })
                }else{
                    layer.msg(ret.msg,{icon:5,time:1500})
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
    })
</script>
</body>
</html>